#define  _CRT_SECURE_NO_WARNINGS 1
//计算
// 列如 sum+=2+22+222+2222
#include<stdio.h>
int main()
{
	int a = 0;
	int n = 0;
	scanf("%d %d", &a, &n);
	int t = 0;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		t = t * 10 + a;
		sum += t;
	}
	printf("%d", sum);
}
// 计算100000的水仙数
#include<stdio.h>
#include<math.h>
int main()
{
	for (int i = 0; i < 999999; i++)
	{
		    int count = 1;
			int t = i;
			int sum = 0;
			while (t/10)//计算出数的位次
			{
				count++;
				t /= 10;
			}
			t = i;//之前改变了t的值
			while(t)//计算每一位的立方
          {
            sum+=pow(t%10,count);
            t/=10;
           }
 
			if (sum==i)//判断
			{
				printf("%d ", i);
			}
	}
	
//用指针的方式打印数组
int main()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int* p = arr;
	for (int i = 0; i <sizeof(arr)/sizeof(arr[0]); i++)
	{
		printf("%d ", *p);
		p++;
	}
}
//饮料计算1块钱换一个饮料，2个瓶盖换1瓶饮料
//方法1
#include<stdio.h>
int main()
{
	int money = 0;
	int sum = 0;
	int empty = 0;
	scanf("%d", &money);
	sum = money;
	empty = money;
	while (empty>1)
	{
		sum += empty / 2;
		empty = empty / 2 + empty % 2;
	}
	printf("%d", sum);
}
//方法2等差数列
#include<stdio.h>
int main()
{
	int moeny = 0;
	scanf("%d", &moeny);
	int sum = 0;
	if (moeny==0)
	{
		sum == 0;
	}
	else
	{
		sum = moeny * 2 - 1;
	}
	printf("%d", sum);

}
//打印菱形图案
#include<stdio.h>
int main()
{
	int i;
	for ( i = 0; i < 7; i++)//上部分
	{
		for (int j =0; j < 6-i; j++) 
		{
			printf(" ");

	    }
		for (int j = 0; j < 2*i+1; j++)
		{
			printf("*");
		}
		printf("\n");
	}

	for ( i = 0; i < 6; i++)//下部分
	{
		for (int j = 0; j <=i;j++)
		{
			printf(" ");

		}
		for (int j = 0; j < 2 * (6-i)-1; j++)
		{
			printf("*");
		}
		printf("\n");
	}
}
//写一个函数实现字符串的逆序
#include<stdio.h>
#include<string.h>
void my_nx(char* str)
{
	char* left = str;//别定义成0
	char* right = str + strlen(str) - 1;

	while (left<right)
	{
	    char t = *left;
		*left = *right;
		*right = t;
		left++;
		right--;
	}
}
int main()
{
	char arr[100];
	gets_s(arr,100);//编译器用的标准不同
	my_nx(arr);
	puts(arr);//printf("%s\n",arr);
}